package com.ude.pim.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {
    //编码，事先约定好每种情况的编码
    //先默认200为成功，404为失败
    private Integer code;

    //错误信息
    private String msg;

    //数据
    private T data;

    public static <T> R<T> success(T object) {
        R<T> r = new R<>();
        r.data = object;
        r.code = 200;
        return r;
    }

    public static <T> R<T> error(String msg) {
        R<T> r = new R<>();
        r.code = 404;
        r.msg = msg;
        return r;
    }

}
